const fs = require('fs/promises')
const path = require('path')

const cwd = process.cwd()
/**
 * 文件写入
 * @date 2021-03-17 16:58:50
 * @param {string} path 输出的路径
 * @return {function(buffer)} 文件输出
*/
const write = (path) => (content) => fs.writeFile(path, content)

/**
 * 文件读取
 * @date 2021-03-17 16:58:50
 * @param {string} src 读取文件的路径
 * @return
*/
const read = (src) => fs.readFile(path.resolve(__dirname, src))

module.exports = (modules) => {
  if (modules === 'utils') {
    read('../template/utilsTemp/utils.js').then(write(path.resolve(cwd, './utils.js')))
  }
}
